<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户信息</title>
<%@ include file="../common/common.jsp"%>
<script type="text/javascript">
var basepath=<%=request.getContextPath()+"/"%>;
$(function(){
    var height = window.document.body.offsetHeight-50;
	$('#staff_info_table').datagrid({ 
		height:height,
		fitColumns:true,
		//fit:true,
		pagination:true,//分页数据
		rownumbers: true,
		loadMsg:'正在加载数据,请稍后',
		pageSize:10,
		url : basepath+'contractInfoAction!loadMainContractInfo.do',
		columns:[[  
		          {field:'clientcode',title:'员工编号',width:100},  
		          {field:'clientname',title:'员工姓名',width:100},  
		          {field:'clientcontract',title:'所属部门',width:100}
	    ]],
	    toolbar : [{
	    	text : '人事信息管理',
	    	iconCls : 'icon-add',
	    	handler : function(){
	    		$('#staff_info_win').window('open');
	    		$('#staff_info_win').window('setTitle','人事信息管理');
	    	}
	    },{
	    	text : '查看',
	    	iconCls : 'icon-ok',
	    	handler : function(){
	    		
	    	}
	    }]

	});
	var editRow = undefined;
	$('#staff_education_info').datagrid({
		title : '二、教育/培训经验',
		height : 200,
		fitColumns : true,
		pagination : false,
		rownumbers : true,
		loadMsg : '',
		pageSize : 4,
		url : "",
		columns : [[
			{field : 'time',title : '起止时间',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入起止时间'                            
					}
				}
			},
			{field : 'org',title : '学习学校/培训机构',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入学习学校/培训机构'                            
					}
				}
			},
			{field : 'a',title : '专业/培训课程',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入专业/培训课程'                            
					}
				}
			},
			{field : 'aa',title : '学历/学位',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入学历/学位'                            
					}
				}
			},
			{field : 'aaa',title : '获得证书',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入获得证书'                            
					}
				} 
            }
		]],
	    onBeforeEdit:function(index,row){
	        row.editing = true;
	        $('#staff_education_info').datagrid('refreshRow', index);
	    },
	    onAfterEdit:function(index,row){
	        row.editing = false;
	        $('#staff_education_info').datagrid('refreshRow', index);
	        editRow = undefined;
	    },
	    onCancelEdit:function(index,row){
	        row.editing = false;
	        $('#staff_education_info').datagrid('refreshRow', index);
	    },
	    toolbar:[{
            text: '添加',
            iconCls: 'icon-add',
            handler: function () {
                if (editRow != undefined) {
                    $("#staff_education_info").datagrid('endEdit', editRow);
                }
                if (editRow == undefined) {
                    $("#staff_education_info").datagrid('insertRow', {
                        index: 0,   // index start with 0
                        row: {
                        }
                    });
                    $("#staff_education_info").datagrid('beginEdit', 0);
                    editRow = 0;
                }
            }
        },'-', {
            text: '修改',
            iconCls: 'icon-edit',
            handler:function () {
                var rows = $("#staff_education_info").datagrid('getSelections');
                if(rows.length==1) {
                    if (editRow != undefined) {
                        $("#staff_education_info").datagrid('endEdit', editRow);
                    }
                    if (editRow == undefined) {
                        var index = $("#staff_education_info").datagrid('getRowIndex',rows[0]);
                        $("#staff_education_info").datagrid('beginEdit', index);
                        editRow = index;
                        //$("#staff_education_info").datagrid('unselectAll');
                    }
                }
            }
        },'-', {
            text: '删除',
            iconCls: 'icon-remove',
            handler:function () {
                var rows = $("#staff_education_info").datagrid('getSelections');
                if (rows.length > 0) {
                     $.messager.confirm('请确认', '您确定要删除当前所有选择的项目吗?', function(b) {
                        if(b) {
                            for (var i = 0; i < rows.length; i++) {
                                var rowIndex = $("#staff_education_info").datagrid('getRowIndex', rows[i]);
                                $("#staff_education_info").datagrid('deleteRow', rowIndex);
                            }
                        }
                    });
                } else {
                    $.messager.alert('提示', '请选择要删除的记录', 'error');
                }
            }
        },'-', {
            text: '完成编辑',
            iconCls: 'icon-save',
            handler:function () {
                $("#staff_education_info").datagrid('endEdit', editRow);
            }
        },'-'/* , {
            text: '取消编辑',
            iconCls: 'icon-redo',
            handler:function () {
                editRow = undefined; 
                $("#staff_education_info").datagrid('rejectChanges');
                $("#staff_education_info").datagrid('unselectAll');
            }
        }, '-' */],   
        onDblClickRow: function (rowIndex, rowData) {
            if (editRow != undefined) {
                $("#staff_education_info").datagrid('endEdit', editRow);
            }
            if (editRow == undefined) {
                $("#staff_education_info").datagrid('beginEdit', rowIndex);
                editRow = rowIndex;
            }

        }
	});
	$('#staff_work_experience_info').datagrid({
		title : '三、工作经历',
		height : 200,
		fitColumns : true,
		pagination : false,
		rownumbers : true,
		loadMsg : '',
		pageSize : 4,
		url : "",
		columns : [[
			{field : 'time',title : '起止时间',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入起止时间'                            
					}
				}
			},
			{field : 'org',title : '工作单位',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入工作单位'                            
					}
				}
			},
			{field : 'a',title : '所在部门',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入所在部门'                            
					}
				}
			},
			{field : 'aa',title : '担任职务',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入担任职务'                            
					}
				}
			},
			{field : 'aaa',title : '离职原因',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入离职原因'                            
					}
				} 
            }
		]],
	    onBeforeEdit:function(index,row){
	        row.editing = true;
	        $('#staff_work_experience_info').datagrid('refreshRow', index);
	    },
	    onAfterEdit:function(index,row){
	        row.editing = false;
	        $('#staff_work_experience_info').datagrid('refreshRow', index);
	        editRow = undefined;
	    },
	    onCancelEdit:function(index,row){
	        row.editing = false;
	        $('#staff_work_experience_info').datagrid('refreshRow', index);
	    },
	    toolbar:[{
            text: '添加',
            iconCls: 'icon-add',
            handler: function () {
                if (editRow != undefined) {
                    $("#staff_work_experience_info").datagrid('endEdit', editRow);
                }
                if (editRow == undefined) {
                    $("#staff_work_experience_info").datagrid('insertRow', {
                        index: 0,   // index start with 0
                        row: {
                        }
                    });
                    $("#staff_work_experience_info").datagrid('beginEdit', 0);
                    editRow = 0;
                }
            }
        },'-', {
            text: '修改',
            iconCls: 'icon-edit',
            handler:function () {
                var rows = $("#staff_work_experience_info").datagrid('getSelections');
                if(rows.length==1) {
                    if (editRow != undefined) {
                        $("#staff_work_experience_info").datagrid('endEdit', editRow);
                    }
                    if (editRow == undefined) {
                        var index = $("#staff_work_experience_info").datagrid('getRowIndex',rows[0]);
                        $("#staff_work_experience_info").datagrid('beginEdit', index);
                        editRow = index;
                        //$("#staff_work_experience_info").datagrid('unselectAll');
                    }
                }
            }
        },'-', {
            text: '删除',
            iconCls: 'icon-remove',
            handler:function () {
                var rows = $("#staff_work_experience_info").datagrid('getSelections');
                if (rows.length > 0) {
                     $.messager.confirm('请确认', '您确定要删除当前所有选择的项目吗?', function(b) {
                        if(b) {
                            for (var i = 0; i < rows.length; i++) {
                                var rowIndex = $("#staff_work_experience_info").datagrid('getRowIndex', rows[i]);
                                $("#staff_work_experience_info").datagrid('deleteRow', rowIndex);
                            }
                        }
                    });
                } else {
                    $.messager.alert('提示', '请选择要删除的记录', 'error');
                }
            }
        },'-', {
            text: '完成编辑',
            iconCls: 'icon-save',
            handler:function () {
                $("#staff_work_experience_info").datagrid('endEdit', editRow);
            }
        },'-'/* , {
            text: '取消编辑',
            iconCls: 'icon-redo',
            handler:function () {
                editRow = undefined; 
                $("#staff_work_experience_info").datagrid('rejectChanges');
                $("#staff_work_experience_info").datagrid('unselectAll');
            }
        }, '-' */],   
        onDblClickRow: function (rowIndex, rowData) {
            if (editRow != undefined) {
                $("#staff_work_experience_info").datagrid('endEdit', editRow);
            }
            if (editRow == undefined) {
                $("#staff_work_experience_info").datagrid('beginEdit', rowIndex);
                editRow = rowIndex;
            }

        }
	});
	$('#staff_family_info').datagrid({
		title : '四、家庭成员',
		height : 200,
		fitColumns : true,
		pagination : false,
		rownumbers : true,
		loadMsg : '',
		pageSize : 4,
		url : "",
		columns : [[
			{field : 'time',title : '姓名',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入姓名'                            
					}
				}
			},
			{field : 'org',title : '与本人关系',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入与本人关系'                            
					}
				}
			},
			{field : 'a',title : '年龄',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入年龄'                            
					}
				}
			},
			{field : 'aa',title : '工作单位',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入工作单位'                            
					}
				}
			},
			{field : 'aaa',title : '担任职务',width : 200,
				editor: {                             
					type: 'validatebox',                             
					options: {                                 
						//required: true,                          
						missingMessage: '请输入担任职务'                            
					}
				} 
            }
		]],
	    onBeforeEdit:function(index,row){
	        row.editing = true;
	        $('#staff_family_info').datagrid('refreshRow', index);
	    },
	    onAfterEdit:function(index,row){
	        row.editing = false;
	        $('#staff_family_info').datagrid('refreshRow', index);
	        editRow = undefined;
	    },
	    onCancelEdit:function(index,row){
	        row.editing = false;
	        $('#staff_family_info').datagrid('refreshRow', index);
	    },
	    toolbar:[{
            text: '添加',
            iconCls: 'icon-add',
            handler: function () {
                if (editRow != undefined) {
                    $("#staff_family_info").datagrid('endEdit', editRow);
                }
                if (editRow == undefined) {
                    $("#staff_family_info").datagrid('insertRow', {
                        index: 0,   // index start with 0
                        row: {
                        }
                    });
                    $("#staff_family_info").datagrid('beginEdit', 0);
                    editRow = 0;
                }
            }
        },'-', {
            text: '修改',
            iconCls: 'icon-edit',
            handler:function () {
                var rows = $("#staff_family_info").datagrid('getSelections');
                if(rows.length==1) {
                    if (editRow != undefined) {
                        $("#staff_family_info").datagrid('endEdit', editRow);
                    }
                    if (editRow == undefined) {
                        var index = $("#staff_family_info").datagrid('getRowIndex',rows[0]);
                        $("#staff_family_info").datagrid('beginEdit', index);
                        editRow = index;
                        //$("#staff_family_info").datagrid('unselectAll');
                    }
                }
            }
        },'-', {
            text: '删除',
            iconCls: 'icon-remove',
            handler:function () {
                var rows = $("#staff_family_info").datagrid('getSelections');
                if (rows.length > 0) {
                     $.messager.confirm('请确认', '您确定要删除当前所有选择的项目吗?', function(b) {
                        if(b) {
                            for (var i = 0; i < rows.length; i++) {
                                var rowIndex = $("#staff_family_info").datagrid('getRowIndex', rows[i]);
                                $("#staff_family_info").datagrid('deleteRow', rowIndex);
                            }
                        }
                    });
                } else {
                    $.messager.alert('提示', '请选择要删除的记录', 'error');
                }
            }
        },'-', {
            text: '完成编辑',
            iconCls: 'icon-save',
            handler:function () {
                $("#staff_family_info").datagrid('endEdit', editRow);
            }
        },'-'/* , {
            text: '取消编辑',
            iconCls: 'icon-redo',
            handler:function () {
                editRow = undefined; 
                $("#staff_family_info").datagrid('rejectChanges');
                $("#staff_family_info").datagrid('unselectAll');
            }
        }, '-' */],   
        onDblClickRow: function (rowIndex, rowData) {
            if (editRow != undefined) {
                $("#staff_family_info").datagrid('endEdit', editRow);
            }
            if (editRow == undefined) {
                $("#staff_family_info").datagrid('beginEdit', rowIndex);
                editRow = rowIndex;
            }

        }
	});
	 $('#win').window({  
		 closable:true,
		 modal:true  
	 });
});
</script>
</head>
<body class="easyui-layout">
	<div region="center"  title="综合业务->人事信息" closable="false" >
		<div  border="false"  id="toolbar">
	         <table id="staff_info_table"></table>  
		</div>
		<div  id = "staff_info_win" class="easyui-window" href=staff_info_add.jsp maximized = "true" data-options="title:'新增表单',iconCls:'icon-save'" closed="true"style="width:800px;height:400px;padding:5px;">
			
		</div>
	</div>
</body>
</html>